Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 4 - Colors and Color-Related Objects / Using Colors and Color-Related Objects


Manipulating the Profile Data in a Color Profile Object

QuickDraw GX defines no structures or types for the profile data of a color profile object. For drawing or converting colors, most applications have no need to access or alter the data in a color profile object. For special needs, however, such as changing the type of match you want to perform, using a custom color-matching method, or inspecting the name of a profile, you can--with knowledge of the details of the CMProfile structure--access and alter the profile data of an existing color profile object. Also, if your application is a calibration program that creates color profiles for devices, or if it is an imaging application that allows users to customize color profiles for specific uses, you need access to profile information in order to make or modify a color profile object.

One way to do this is to use ColorSync functions to manipulate a ColorSync profile directly, and then use the QuickDraw GX function GXNewColorProfile to convert it to a color profile object. ColorSync profiles are commonly in the ColorSync profiles folder on the user's system, and ColorSync can provide you with a list of those profiles.

More directly, you can call the GXGetColorProfile function to obtain the profile data for a given profile. Knowing the structure of a ColorSync color profile, you can then modify that information as needed, and return the altered data to the color profile object by calling the GXSetColorProfile function.

Note
If you alter the header of a ColorSync color profile to specify a particular color space in the dataType field, and then apply that profile to a color defined in terms of a different color space, QuickDraw GX ignores the new header data and specifies the color space implied by the color value you pass to the profile.
Yet another approach is to directly modify the profile data of a color profile object
in place, in QuickDraw GX memory. First, you call the GXLockColorProfile
function to prevent the profile data from being relocated, and then you call GXGetColorProfileStructure to get a pointer to the profile data. After manipulating the data, you must call GXUnlockColorProfile to release the
data for relocation. Remember that you cannot change the size of the profile data
with these calls, only its contents; if your manipulations require a change in the
size of the data, you must use GXGetColorProfile and GXSetColorProfile.

IMPORTANT
Memory-handling complications can occur with locked objects. Locking an object fragments the QuickDraw GX heap, which can result in lower performance. Furthermore, if a fragmented-memory condition occurs during a call, QuickDraw GX may unlock all objects and restart the call. Therefore, be careful about performing memory-intensive operations while there are locked objects in QuickDraw GX memory; they may become unlocked without warning.
The GXNewColorProfile function is described on page 4-79. The GXGetColorProfile function is described on page 4-88. The GXSetColorProfile function is described on page 4-89. The GXLockColorProfile function is described
on page 4-90. The GXGetColorProfileStructure function is described on page 4-92.The GXUnlockColorProfile function is described on page 4-91.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996